Find Maximum in Sliding Window
Try to solve the Find Maximum in Sliding Window problem.
We'll cover the following
1 of 3
2 of 3
3 of 3
Understand the problem#
Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps us to check if you’re solving the correct problem:
Find Maximum in Sliding Window
What should be the output if the following input is given?
nums = [1, 2, 3, 1, 4, 5, 2, 3, 6]
w = 3
[2, 3, 5, 3]
[3, 2, 4, 5, 5, 6]
[3, 3, 4, 5, 5, 5, 6]
The first window of size is [1, 2, 3], and the maximum in this window is 3. The second window of size is [2, 3, 1], and the maximum in this window is also 3. The third window of size is [3, 1, 4], and the maximum in this window is 4. The fourth window of size is [1, 4, 5], and the maximum in this window is 5. The fifth window of size is [4, 5, 2], and the maximum in this window is also 5. The sixth window of size is [5, 2, 3], and the maximum in this window is also 5. The seventh and the last window of size is [2, 3, 6], and the maximum in this window is .
[1, 2, 3, 1, 4, 5, 2]
Figure it out!#
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Try it yourself#
Implement your solution in the following coding playground:
Solution: Repeated DNA Sequences
Solution: Find Maximum in Sliding Window